package com.ming.controller;

import com.ming.common.Result;
import com.ming.common.validator.ValidatorUtil;
import com.ming.from.BookRentForm;
import com.ming.query.BookRentQuery;
import com.ming.service.BookRentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @Author:何元才
 * @Desc:
 * @data:2021-04-27 15:10
 */
@RestController
@RequestMapping("bookRent")
public class  BookRentController {

    @Autowired
    private BookRentService bookRentService;

    /**
     * 分页查询借阅纪录
     *
     * @param query
     * @return
     */
    @RequestMapping("page.do")
    public Object page(BookRentQuery query) {
        Result rs = bookRentService.queryPage(query);
        return rs;
    }

    /**
     * 借阅图书  图书管理员操作的借阅
     * @param form
     * @return
     */
    @RequestMapping("rent.do")
    public Object add(BookRentForm form) {
        ValidatorUtil.validator(form);
        Result rs = bookRentService.rent(form);
        return rs;
    }

}
